<?php
namespace app\admin\controller;

use think\facade\Db;
use utils\TokenUtil;

class Index extends BaseController
{
    public function index()
    {
        return '<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }</style><div style="padding: 24px 48px;"> <h1>:) </h1><p> ThinkPHP V' . \think\facade\App::version() . '<br/><span style="font-size:30px;">14载初心不改 - 你值得信赖的PHP框架</span></p><span style="font-size:25px;">[ V6.0 版本由 <a href="https://www.yisu.com/" target="yisu">亿速云</a> 独家赞助发布 ]</span></div><script type="text/javascript" src="https://tajs.qq.com/stats?sId=64890268" charset="UTF-8"></script><script type="text/javascript" src="https://e.topthink.com/Public/static/client.js"></script><think id="ee9b1aa918103c4fc"></think>';
    }

    public function hello($name = 'ThinkPHP6')
    {
        return 'hello,' . $name;
    }
    //数据库测试
    public function testSql($name = 'ThinkPHP6')
    {
        $good=Db::table('t_user')->where('id', 1)->find();
        dump($good);die();
    }
    //jwt测试
    public function testJwt($name = 'ThinkPHP6')
    {
        {
//            echo encrypt_password('123456');die;
            //测试Token工具类
            //生成token
            $token = TokenUtil::getToken(200);
            dump($token);
            //解析token 得到用户id
            $user_id = TokenUtil::getUserId($token);
            dump($user_id);die;

            //测试响应方法

            //$this->response();
            //$this->response(200, 'success', ['id' => 100, 'name' => 'zhangsan']);
            //$this->ok(['id' => 100, 'name' => 'zhangsan']);
            //$this->response(400, '参数错误');
            //$this->fail('参数错误');
            //$this->fail('参数错误', 401);
            //测试数据库配置
//        $goods = \think\Db::table('pyg_goods')->find();
//        dump($goods);die;
            //return 'hello, 这里是adminapi的index的index方法';
        }
    }
}
